'Uses the text to be encrypted and a code key to XOr 2 values together and come up with an encrypted string.

'Copy the declarations and code below and paste directly into your VB project.

Public Function XOREncryption(CodeKey As String, DataIn As String) As String
    Dim lonDataPtr As Long
    Dim strDataOut As String
    Dim intXOrValue1 As Integer, intXOrValue2 As Integer


    For lonDataPtr = 1 To Len(DataIn)
        'The first value to be XOr-ed comes from
        '     the data to be encrypted
        intXOrValue1 = Asc(Mid$(DataIn, lonDataPtr, 1))
        'The second value comes from the code ke
        '     y
        intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
        strDataOut = strDataOut + chr(intXOrValue1 XOr intXOrValue2)
    Next lonDataPtr
   XOREncryption = strDataOut
End Function

'USAGE
Private Sub cmdEncryptdecrypt_Click()
    Dim strCodeKey As String
    strCodeKey = InputBox("Please enter your password", "XOr Encryption")
    txtSource.Text = XOREncryption(strCodeKey, txtSource.Text)


End Sub